<template>
	<view>
		<!-- 广告插入 -->
		<adview :title="title" @adfun="adfun"></adview>
		<web-view v-if="!adShow" :src="view_url"></web-view>
		<!-- <web-view :src="view_url"></web-view> -->
	</view>
</template>

<script>
import adview from '@/components/adview/adview.vue';
export default {
	components: { adview },
	data() {
		return {
			view_url: '',
			title: '',
			adShow: true,
			navIndex: null
		};
	},
	watch: {
		adShow(newV) {
			// console.log('newv', newV);
			this.adShow = newV;
		}
	},
	onLoad(option) {
		this.view_url = decodeURIComponent(option.url);
		// this.view_url = option.url;
		this.title = option.title;
		this.navIndex = option.navIndex;
		uni.setNavigationBarTitle({
			title: option.title
		});
		this.getInfo();
		// 分享
		wx.showShareMenu({
			withShareTicket: true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
	},
	//分享到聊天
	onShareAppMessage(res) {
		return {
			title: ' ',
			path: '/subPages/web_view_h5/index?url=' + this.view_url + '&navIndex=' + this.navIndex + '&title=' + this.title //界面路径
		};
	},
	// 分享到朋友圈
	onShareTimeline(res) {
		return {
			title: this.title,
			path: '/subPages/web_view_h5/index?url=' + this.view_url + '&navIndex=' + this.navIndex + '&title=' + this.title
		};
	},
	methods: {
		getInfo() {
			// this.loadShow = true;
			// setTimeout(() => {
			// 	this.loadShow = false;
			// }, 1500);
		},
		adfun(val) {
			this.adShow = val;
		}
	}
};
</script>

<style lang="scss" scoped>
.load_box {
	margin: 0 auto;
}
</style>
